package learn;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public class MapTT {

	public static void main(String[] args) {
		
		test_map1();
		test_map2();
		test_recommend_map_iter();

	}
	
	private static void test_recommend_map_iter() {
		HashMap<String, String> hashMap = new HashMap<String, String>();
		hashMap.put("item-0", "Value-000");
		hashMap.put("item-1", "Value-001");
		hashMap.put("item-2", "Value-002");
		hashMap.put("item-3", "Value-003");
		
		for (String key : hashMap.keySet()) {
			String value = hashMap.get(key);
			System.out.println(value);
		}
		
		for (Entry<String, String> entry: hashMap.entrySet()) {
			String key = entry.getKey();
			String value = entry.getValue();
			System.out.println(key + ":" + value);
		}
		
		for (String value : hashMap.values()) {
			System.out.println(value);
		}
		
		
	}

	private static void test_map2() {
		HashMap<String, String> hashMap = new HashMap<String, String>();
		hashMap.put("item-0", "Value-000");
		hashMap.put("item-1", "Value-001");
		hashMap.put("item-2", "Value-002");
		hashMap.put("item-3", "Value-003");
		
		for(String key: hashMap.keySet()) {
			String value = hashMap.get(key);
			System.out.println(value);
		}
		
	}

	private static void test_map1() {
		HashMap<String, String> hashMap = new HashMap<String, String>();
		hashMap.put("item-0", "Value-000");
		hashMap.put("item-1", "Value-001");
		hashMap.put("item-2", "Value-002");
		hashMap.put("item-3", "Value-003");
		
		Set<Entry<String, String>> set = hashMap.entrySet();
		Iterator<Entry<String, String>> iter = set.iterator();
		while(iter.hasNext()) {
			Map.Entry<String, String> entry = iter.next();
			System.out.println(entry.getKey() + ":" + entry.getValue());
		}
	}

}
